//
//  AYBIdentificationTool.m
//  Ayibang
//
//  Created by 小胖的Mac on 15/11/25.
//  Copyright (c) 2015年 ayibang. All rights reserved.
//

#import "AYBIdentificationTool.h"
#define KEY_UDID            @"KEY_UDID"
#define KEY_IN_KEYCHAIN     @"KEY_IN_KEYCHAIN"

@interface AYBIdentificationTool (){
    NSString *_udid;
}

@end

@implementation AYBIdentificationTool
single_implementation(AYBIdentificationTool)

- (NSString *)readUDID{
       // 从钥匙串中读取 _uuid
      _udid = [SSKeychain passwordForService:KEY_UDID account:KEY_IN_KEYCHAIN];
    if (_udid == nil || _udid.length == 0) {
        NSString * udid = [self openUDID];
        [SSKeychain setPassword:udid forService:KEY_UDID account:KEY_IN_KEYCHAIN];
        _udid = udid;
    }

    return _udid?_udid:@"";
}
- (NSString *)openUDID
{
    NSString *identifierForVendor = [[UIDevice currentDevice].identifierForVendor UUIDString];
    return identifierForVendor;
}


@end
